package com.woniuxy.demo.epai.controller.component;


import com.woniuxy.demo.epai.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handleException(Exception e) {
        System.out.println("出现异常:" + e.getMessage());
        e.printStackTrace();
        return Result.fail("服务器开了个小差，程序员小哥正在努力修复，请稍等。错误提示：" + e.getMessage());
    }

}
